<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    /*return view('welcome');*/
    echo date('Y-m-d H:i:s',time());
    echo Config::get('app.timezone');
    echo Config::get('app.key');
    echo Config::set('app.timezone','UTC');
    echo Config::get('app.timenzone');
    echo '<br>';
   echo Config::get('app.webname');
});
//创建一个普通的get请求
Route::get('/test',function(){
	return view('post');
});
//创建一个普通的post请求
Route::post('/post',function(){
	var_dump($_POST);
});
//创建一个带参数的路由
Route::get('/name/delete/{id}-{name}-{class}',function($name,$id,$class){
	echo '这又是一个测试'.$id.$name.$class;
})->where('id','[0-9+]')->where('name','[a-zA-Z_]+');
//创建一个带别名的路由
Route::get('/admin/user/delete/{id}',['as'=>'aa',function(){
	echo '这就是一个测试';
	echo route('aa');
}]);
//创建一组路由
Route::group(['middleware'=>'login'],function(){
	Route::get('/test/user',function(){echo '这是用户管理';});
	Route::get('/test/goods',function(){echo '这是商品管理';});
	Route::get('/test/order',function(){ echo '这是订单管理';});
});
Route::get('/login',function(){
	echo '这是用户登录界面';
});
Route::get('/user/login',function(){

})->middleware('login');
//发送ajax
Route::get('/ajax',function(){
	return view('ajax');
});
Route::get('getinfo',function(){
	echo '这是一个ajax的post方式';
});
Route::post('/postinfo',function(){
	echo '这是一个ajax的post方式';
});
Route::get('/user/index','UserController@index');
Route::get('/user/add','UserController@add');
Route::post('/user/insert','UserController@insert');
Route::get('/user/edit/{id}','UserController@edit');
Route::get('/user/delete',['as'=>'ud','uses'=>'UserController@delete'])->middleware('login');

//隐式路由
Route::controller('/goods','GoodsController');
Route::controller('/test','TestController');
//用户路由
Route::controller('/admin/user','admin\UserController');